package com.tang.algorithm.ordinary;

/**
 * @author tlm
 * @version 1.0
 * @date 2020/7/16 21:09
 */
public class LeetCode1299 {
    public int[] replaceElements(int[] arr) {
        int[] result = new int[arr.length];
        int max = -1;
        result[arr.length - 1] = -1;
        for(int i = arr.length - 2; i >= 0; i--)
        {
            if(arr[i + 1] > max)
            {
                max = arr[i + 1];
            }
            result[i] = max;
        }
        return result;
    }
}
